// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.iso.areas.isoregion;

import java.nio.ByteBuffer;
import zombie.iso.IsoChunk;
import zombie.iso.IsoGridSquare;

public class ChunkUpdate {
    public static void writeIsoChunkIntoBuffer(IsoChunk c, ByteBuffer bb) {
        if (c != null) {
            int int0 = bb.position();
            bb.putInt(0);
            bb.putInt(c.maxLevel);
            int int1 = (c.maxLevel + 1) * 100;
            bb.putInt(int1);

            for (int int2 = 0; int2 <= c.maxLevel; int2++) {
                for (int int3 = 0; int3 < c.squares[0].length; int3++) {
                    IsoGridSquare isoGridSquare = c.squares[int2][int3];
                    byte _byte = IsoRegions.calculateSquareFlags(isoGridSquare);
                    bb.put(_byte);
                }
            }

            int int4 = bb.position();
            bb.position(int0);
            bb.putInt(int4 - int0);
            bb.position(int4);
        } else {
            bb.putInt(-1);
        }
    }
}
